﻿/*
 * Copyright (C) 2012, Jesus Requejo <jesus.requejo@gmail.com> 
 * Licensed under Microsoft Public License (Ms-PL)
 * http://www.microsoft.com/en-us/openness/licenses.aspx#MPL
*/

namespace Infrastructure {

   using Microsoft.Win32;
   
   public static class RegistryManager {

      public static string ReadInstallationPath() {
         var key = GetProductKeyInRegistry();
         var path = key.GetValue(MagicStrings.InstallationPathRegistryValue);        
         return path as string;
      }

      public static string ReadProductCode() {
         var key = GetProductKeyInRegistry();
         var path = key.GetValue(MagicStrings.ProductCodeRegistryValue);
         return path as string;
      }

      private static RegistryKey GetProductKeyInRegistry() {
         var keyName = Infrastructure.MagicStrings.ManufacturerRegistryKey;
         var key = Registry.LocalMachine.OpenSubKey(keyName);
         return key;
      }
   }
}
